package com.zzw.hj5;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 进制转换
 * @Author: zzw
 */

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        String hexStr = str.substring(2);
        //System.out.println(hexStr);
        int num = 0;
        char[] charArray = hexStr.toCharArray();
        for (int i = 0; i < charArray.length; i++) {
            if (charArray[i] >= '0' && charArray[i] <= '9') {
                // '0'的ASCII码是48
                charArray[i] -= 48;
            }
            if (charArray[i] >= 'A' && charArray[i] <= 'F') {
                // 'A'的ASCII码是65
                charArray[i] -= 55;
            }
            num += (int) charArray[i] * Math.pow(16, charArray.length - i - 1);
        }
        System.out.println(num);
    }
}